INSERT INTO `la_system_auth_menu` (pid,menu_type,menu_name,menu_icon,menu_sort,perms,paths,component,selected,params,is_cache,is_show,is_disable)
select 600, 'C', '{{{function_name}}}', 'el-icon-Apple', 0, '{{{module_name}}}:{{{entity_snake_name}}}:list', '{{{entity_snake_name}}}', '{{{module_name}}}/{{{entity_snake_name}}}/{% if gen_tpl=='tree' %}index-tree{% else %}index{% endif %}', '', '', 1, 1, 0
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1
    FROM `la_system_auth_menu`
    WHERE menu_name='{{{function_name}}}'
);
SET @pid = (SELECT id FROM la_system_auth_menu WHERE menu_name = '{{{function_name}}}');
INSERT INTO `la_system_auth_menu` (pid,menu_type,menu_name,menu_icon,menu_sort,perms,paths,component,selected,params,is_cache,is_show,is_disable)
select @pid, 'A', '{{{function_name}}}详情', '', 0, '{{{module_name}}}:{{{entity_snake_name}}}:detail', '', '', '', '', 1, 1, 0
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1
    FROM `la_system_auth_menu`
    WHERE pid = @pid and menu_name='{{{function_name}}}详情'
);
INSERT INTO `la_system_auth_menu` (pid,menu_type,menu_name,menu_icon,menu_sort,perms,paths,component,selected,params,is_cache,is_show,is_disable)
select @pid, 'A', '{{{function_name}}}新增', '', 0, '{{{module_name}}}:{{{entity_snake_name}}}:add', '', '', '', '', 1, 1, 0
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1
    FROM `la_system_auth_menu`
    WHERE pid = @pid and menu_name='{{{function_name}}}新增'
);
INSERT INTO `la_system_auth_menu` (pid,menu_type,menu_name,menu_icon,menu_sort,perms,paths,component,selected,params,is_cache,is_show,is_disable)
select @pid, 'A', '{{{function_name}}}编辑', '', 0, '{{{module_name}}}:{{{entity_snake_name}}}:edit', '', '', '', '', 1, 1, 0
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1
    FROM `la_system_auth_menu`
    WHERE pid = @pid and menu_name='{{{function_name}}}编辑'
);
INSERT INTO `la_system_auth_menu` (pid,menu_type,menu_name,menu_icon,menu_sort,perms,paths,component,selected,params,is_cache,is_show,is_disable)
select @pid, 'A', '{{{function_name}}}删除', '', 0, '{{{module_name}}}:{{{entity_snake_name}}}:delete', '', '', '', '', 1, 1, 0
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1
    FROM `la_system_auth_menu`
    WHERE pid = @pid and menu_name='{{{function_name}}}删除'
);
{% if table.is_basic_data %}
set @type_id=(select id from la_dict_type where dict_type='basic_data');
INSERT INTO `la_dict_data` (type_id,name,value,sort)
SELECT @type_id,'{{{function_name}}}','{{{entity_name}}}',0
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1
    FROM `la_dict_data`
    WHERE type_id = @type_id and value='{{{entity_name}}}'
);
{% endif %}